package client.appstate;

import client.ClientMain;

import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.asset.AssetManager;
import com.jme3.bullet.BulletAppState;
import com.jme3.input.InputManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;

public class MenuState extends AbstractAppState{

	private ClientMain app;
	private Node rootNode;
	private Node stateRootNode;
	private AssetManager assetManager;
	private AppStateManager stateManager;
	private InputManager inputManager;
	private ViewPort viewPort;
	private BulletAppState bullet;

	public void initialize(AppStateManager stateManager, Application app) {
		super.initialize(stateManager, app);
		this.app = (ClientMain) app;
		this.rootNode = this.app.getRootNode();
		this.assetManager = this.app.getAssetManager();
		this.stateManager = this.app.getStateManager();
		this.inputManager = this.app.getInputManager();
		this.viewPort = this.app.getViewPort();
		this.bullet = this.stateManager.getState(BulletAppState.class);
	}
	

	@Override
	public void setEnabled(boolean enabled) {
		super.setEnabled(enabled);
		
		if(enabled)
		{
			rootNode.attachChild(stateRootNode);
		}
		else
		{
			rootNode.detachChild(stateRootNode);
		}
	}
	
	@Override
	public void cleanup() {
		super.cleanup();
		
		rootNode.detachChild(stateRootNode);
	}
}
